package Demo5.Demo2;

import java.util.Scanner;

/**
 * @Author:LiRegin
 * @Date: 2019/12/4 20:40:57
 */
public class Demo1 {
    public static void main(String[] args) throws Exception {
        System.out.println("请输入第一个数字");
        int one=stringToNumber(new Scanner(System.in).nextLine());
        System.out.println("请输入第二个数字");
        int two=stringToNumber(new Scanner(System.in).nextLine());
        System.out.println("两束之和为："+(one+two));
    }
    public static int stringToNumber(String s) throws Exception{
        int i=0;
        try {
            i=Integer.parseInt(s);
        } catch (NumberFormatException e) {
            throw new Exception("输入类型错误！！！");
        }
        return i;
    }
}
